#ifndef FORMCFGSETTINGS_H
#define FORMCFGSETTINGS_H


#include <QFileDialog>
#include <QShowEvent>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QStringList>
#include <QVariant>
#include <QWidget>

#include "install.h"
#include "databasemanager.h"
#include "bootrulesetconfig.h"

namespace Ui {
class FormCfgSettings;
}

/**
\file formcfgsettings.h
\class FormCfgSettings

\brief Maintain application configuration settings


***************************/
class FormCfgSettings : public QWidget
{
    Q_OBJECT

public:
    explicit FormCfgSettings(QWidget *parent = 0);
    ~FormCfgSettings();

public slots:

    /**
    \brief Wrapper for file dialogue used to select iptables location
      ***********************/
    virtual void slotIptables();


    /**
    \brief Wrapper for file dialogue used to select shell location
      ***********************/
    virtual void slotShell();

    /**
    \brief Wrapper for file dialogue used to select directory for temporary files
      ***********************/
    virtual void slotTempDir();



    /**
    \brief Save Configuration to table
      *****************/
    virtual void slotSave();

    /**
    \brief Cancel any changes made to configuration by reloading defaults from table
      ***********************/
    virtual void slotCancel();

    /**
    \brief Change button enabled state depending on edit state
      *****************/
    virtual void slotButtonStateEnabled();

    /**
    \brief Change button enabled state depending on edit state
      *****************/
    virtual void slotButtonStateDisabled();


protected:

    DatabaseManager *databaseManager;
    QSqlQuery qry;
    QPointer<BootRulesetConfig> bootRulesetConfig;

    int id;
    QString shell;
    QString iptables;
    QString tempdir;
    QString defaultRuleName;
    QString bootRuleName;
    QString bootMechanism;
    /**
    \brief Load configuration settings from table
      ***********************/
    virtual void loadSettings();

    /**
    \brief Save configuration settings to table
      ***********************/
    virtual void saveSettings();


    virtual void showEvent(QShowEvent *event);

    /**
    \brief Return last error if any from last executed SQL command
    \return Error string
      *****************/
    virtual QString lastSqlErrorAsString();

private:
    Ui::FormCfgSettings *ui;
};

#endif // FORMCFGSETTINGS_H
